package com.doudou.collection.service.impl;

import com.doudou.collection.mapper.UserDetailMapper;

import com.doudou.collection.pojo.vo.UserDetailFansAndFollowVO;
import com.doudou.collection.pojo.vo.UserSimpleVO;
import com.doudou.collection.response.ResultVO;
import com.doudou.collection.service.UserDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 个人信息模块业务逻辑类实现类
 */

@Slf4j
@Service
public class UserDetailImpl implements UserDetailService {


    @Autowired
    UserDetailMapper userDetailMapper;


    /**
     * 查询当前用户的粉丝列表
     * @param id
     * @return
     */
    @Override
    public ResultVO selectFansListById(Long id) {
        List<UserSimpleVO> list = userDetailMapper.selectFansListById(id);
        log.info("查询成功");
        return ResultVO.ok(list);
    }

    /**
     * 查询当前用户关注列表
     * @param id
     * @return
     */
    @Override
    public ResultVO selectFollowListById(Long id) {
        List<UserSimpleVO> list = userDetailMapper.selectFollowListById(id);
        log.info("查询成功 {}", list);

        return ResultVO.ok(list);
    }

    /**
     * 查询当前用户粉丝数
     * @param id
     * @return
     */
    @Override
    public ResultVO selectFansCountById(Long id) {
        UserDetailFansAndFollowVO fansAndFollowVO = userDetailMapper.selectFansCountById(id);
        log.info("查询成功");
        return ResultVO.ok(fansAndFollowVO);
    }

    /**
     * 查询当前用户关注数
     * @param id
     * @return
     */
    @Override
    public ResultVO selectFollowsCountById(Long id) {
        UserDetailFansAndFollowVO fansAndFollowVO = userDetailMapper.selectFollowsCountById(id);
        log.info("查询成功");
        return ResultVO.ok(fansAndFollowVO);
    }
}
